﻿
//初始化
if (typeof ($) != "undefined") {
    $(document).ready(function () {
        var stepType = getPar(decodeURI(location.href), "stepType"); //是初选还是筛选
        var id = getPar(decodeURI(location.href), "id"); //获取ID
        var fun = getPar(decodeURI(location.href), "fun"); //是否是查看
        $("#StepType").val(stepType);
        var entityConst = "V_hrSelectPrimariesCandidate";
        var functioid = "449E1E63-FF94-453B-9CD7-3928C2576524";
        parent.document.getElementById("dialog6_h").innerHTML = "选择应聘人"; //
        if (stepType == "2") //筛选
        {
            $("#divTitleStep").text("筛选步骤：");
            $("#divTitleDate").text("筛选日期：");
            $("#divTitleCentent").text("筛选内容：");
            $("#divTitleComment").text("筛选意见：");
            $("#divTitleResult").text("筛选结果：");
            $("#divTitleOver").text("筛选结束：");
            entityConst = "V_hrSelectFilterCandidate";
            functioid = "5843AD74-8093-4493-9573-79232B637D16";
            parent.document.getElementById("dialog6_h").innerHTML = "选择应聘人——初选通过"; //
        }
        $("#btnSelect").click(function (event) { //单击选择，选择应聘人  
            parent.document.getElementById("EditUIWindow6").src = "YUIDataTableList.aspx?entity=" + entityConst + "&isShonwBtn=N&functionid=" + functioid;
            parent.ShowDialogWindow();
        });

        $("#isOverFlag").change(function () { //初选是否结束
            var obj = document.getElementById("isOverFlag");
            if (obj.checked) {
                instance[0].StepOverFlag = "1";
            }
            else {
                instance[0].StepOverFlag = "0";
            }
        });
        if (id != "" && id != "undefined") { //修改
            var planName = getPar(decodeURI(location.href), "planName");
            var postName = getPar(decodeURI(location.href), "postName");
            var name = getPar(decodeURI(location.href), "name");
            var idCard = getPar(decodeURI(location.href), "idCard");
            var auditMan = getPar(decodeURI(location.href), "auditMan");
            $("#PlanName").val(planName);
            $("#PostName").val(postName);
            $("#Name").val(name);
            $("#IdCard").val(idCard);
            $("#txtStepAuditMen").val(auditMan);
            $("#btnSelect").attr("disabled", true);
            $("#PlanName").attr("disabled", true);
            $("#PostName").attr("disabled", true);
            $("#Name").attr("disabled", true);
            $("#IdCard").attr("disabled", true);
            if (instance[0].StepOverFlag == "1") {
                var obj = document.getElementById("isOverFlag");
                obj.checked = true;
            }
            if (fun == "view") { //查看
                $("#StepWay").attr("disabled", true);
                $("#StepDate").attr("disabled", true);
                $("#StepContent").attr("disabled", true);
                $("#StepComment").attr("disabled", true);
                $("#StepResult").attr("disabled", true);
                $("#txtStepAuditMen").attr("disabled", true);
                $("#btnStepAuditMen").attr("disabled", true);
                $("#isOverFlag").attr("disabled", true);
                var btn = parent.document.getElementById("yui-gen7-button");
                $(btn).hide();
            }
        }
        else {   //新增
            instance[0].StepOverFlag = "0";
        }
    });
}

//查看面试记录
function fnViewRecords() {
    if ($("#Name").val() == "") {
        alert("请先选择应聘人！");
        return;
    }
    var candidateId = $("#CandidateID").val();
    var stepType = getPar(decodeURI(location.href), "stepType"); //是初选还是筛选
    var planName = $("#PlanName").val();
    var postName = $("#PostName").val();
    var name = $("#Name").val();
    var idCard = $("#IdCard").val();
    var pagetitle = "查看面试记录";
    parent.parent.addTabs(pagetitle, encodeURI("../EHR/hrViewInterviewRecords.aspx?stepType=" + stepType + "&planName=" + planName + "&postName=" + postName + "&name=" + name + "&idCard=" + idCard + "&candidateId=" + candidateId));
    parent.parent.NeedRefreshPage = this;
}

//var ValueChanged = function () { //选择考核人后
//debugger
//    var auditMan = $("#StepAuditMen").val();
//    instance[0].StepAuditMen = auditMan;
//}

var fnCheckData = function () {
    var stepType = getPar(decodeURI(location.href), "stepType"); //是初选还是筛选
    var stepDateTip = "初选日期";
    var stepRsTip = "初选结果";
    if (stepType == "2") //筛选
    {
        stepDateTip = "筛选日期";
        stepRsTip = "筛选结果";
    }
    if ($("#Name").val() == "") {
        return "应聘人姓名不能为空！";
    }
    if ($("#StepDate").val() == "") {
        return stepDateTip + "不能为空！";
    }
    if ($("#StepResult").val() == "") {
        return stepRsTip + "不能为空！";
    }
}